//头部轮播图
function head(){
    var swiper = new Swiper(".mySwiper", {
        spaceBetween: 30,
        centeredSlides: true,
        autoplay: {
            delay: 1500,
            disableOnInteraction: false,
        },
        pagination: {
            el: ".swiper-pagination",
            clickable: true,
        },
        navigation: {
            nextEl: ".swiper-button-next",
            prevEl: ".swiper-button-prev",
        },
    });
}
head()


//API移入移出颜色改变
function APIel() {
    let imgC = ["./images/api01-c.svg", "./images/api02-c.svg", "./images/api03-c.svg", "./images/api04-c.svg", "./images/api05-c.svg", "./images/api06-c.svg", "./images/api07-c.svg", "./images/api08-c.svg", "./images/apic1-c.svg", "./images/apic2-c.svg"]
    let img = document.querySelectorAll(".service-API ul li img")
    let imgy = []
    img.forEach((i) => {
        imgy.push(i.src)
    });
    let p = document.querySelectorAll(".service-API ul li p")
    let li = document.querySelectorAll(".service-API ul li")
    li.forEach((i, j) => {
        i.addEventListener("mouseenter", function () {
            i.style.backgroundColor = "#1271f2"
            img[j].src = imgC[j]
            p[j].style.color = "#fff"
        })
        i.addEventListener("mouseleave", function () {
            i.style.backgroundColor = "#ffffff"
            img[j].src = imgy[j]
            p[j].style.color = "#000000"
        })
    });
}
APIel()

//助力行业巨头 / 独角兽企业 轮播图
let timeId = null
let index = 0
function whoServed() {
    let li = document.querySelectorAll(".who-served .columns ul li")
    timeId = setInterval(() => {
        li[index].classList.remove("on")
        index++
        if (index === 3) {
            index = 0
        }
        li[index].classList.add("on")
    }, 1500);
}
whoServed()
//移入暂停
function MoveOut() {
    let columns = document.querySelector(".who-served .columns")
    columns.addEventListener("mouseenter", function () {
        clearInterval(timeId)
        timeId = null
    })
    columns.addEventListener("mouseleave", function () {
        whoServed()
    })
}
MoveOut()


//助力行业巨头 / 独角兽企业  合作企业
function enterprise() {
    // let imgEnterprise = ["./images/more-partners-item01.svg", "./images/more-partners-item02.svg", "./images/more-partners-item03.svg", "./images/more-partners-item04.svg", "./images/more-partners-item05.svg", "./images/more-partners-item06.svg", "./images/more-partners-item07.svg", "./images/more-partners-item08.svg"]
    let img = document.querySelectorAll(".who-served-sponsor img")
    let imgy = []
    img.forEach((i) => {
        imgy.push(i.src)
    });
    img.forEach((k, j) => {
        let s=j+1
        k.addEventListener("mouseenter", function () {
            img[j].src = `./images/more-partners-item${s<10? '0' + s : s}.svg`
        })
        k.addEventListener("mouseleave", function () {
            img[j].src = imgy[j]
        })
    });
}
enterprise()



//回到顶部按钮
//1.移入移出图片切换
function ImageSwitching() {
    let div = document.querySelector(".Back-to-the-top")
    div.addEventListener("mouseenter", function () {
        div.style.backgroundPosition = "-162px -97px"
    })
    div.addEventListener("mouseleave", function () {
        div.style.backgroundPosition = "-162px -56px"
    })
}
ImageSwitching()
//2.点击图片回到顶部
function roll() {
    let divRoll = document.querySelector(".Back-to-the-top")
    let timeId = null
    divRoll.addEventListener("click", function () {
        if (timeId) {
            return
        }
        timeId = setInterval(() => {
            document.documentElement.scrollTop -= 50
            if (document.documentElement.scrollTop <= 0) {
                clearInterval(timeId)
                timeId = null
            }
        }, 50);
    })
}
roll()